# -*- coding: utf-8 -*-
"""
从高维数据向低维数据的映射
Created on Thu Mar 29 08:55:39 2018

@author: Allen
"""
import numpy as np
import matplotlib.pyplot as plt

X = np.empty( ( 100, 2 ) )
X[:,0] = np.random.uniform( 0., 100., size = 100 )
X[:,1] = 0.75 * X[:,0] + 3. + np.random.normal( 0, 10, size=100 )

from playML.PCA import PCA

pca = PCA( n_components = 2 )
pca.fit( X )
print( pca.components_ )
'''
[[ 0.80139797  0.5981315 ]
 [ 0.59813647 -0.80139426]]
'''
X_reduction = pca.transform( X )

X_restore = pca.inverse_transform( X_reduction )


